package com.monkeyboy.controller;

import com.monkeyboy.common.dto.ResData;
import com.monkeyboy.model.SysJob;
import com.monkeyboy.service.SystemJobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @Author Gavin
 * @date 2020.07.07 18:22
 */
@RestController
@RequestMapping("/system/job")
public class SystemJobController {
    @Autowired
    private SystemJobService systemJobService;

    /**
     * 获取定时任务列表
     *
     * @Param
     * @Date 2020.07.08 15:56
     **/
    @PreAuthorize("@permissionService.hasPermi('system:job:list1') ")
    @GetMapping("/list")
    public ResData getJobList() throws Exception {
        return systemJobService.getJobList();
    }

    /**
     * 新增定时任务
     */
    @PostMapping("/insertOneJob")
    public ResData insertOneJob(@RequestBody SysJob job) throws Exception {
        return systemJobService.insertOneJob(job);
    }

    /**
     * 改变定时任务的状态
     *
     * @Param
     * @Date 2020.07.08 15:56
     **/
    @PostMapping("/changeStatus")
    public ResData changeStatus(@RequestBody SysJob job) throws Exception {
        return systemJobService.changeStatus(job);
    }

    /**
     * 导出定时任务
     *
     * @Param
     * @Date 2020.07.09 11:22
     **/
    @PreAuthorize("@permissionService.hasPermi('system:job:export')")
    @GetMapping("/export")
    public ResData export(SysJob sysJob) throws Exception {
        return systemJobService.export(sysJob);
    }
}
